<template>
	<view class="we_login_btn" @tap="submitWeLogin">
		<image class="we_icon" src="@/static/iconImg/weChat_login.png"></image>
	</view>
</template>

<script>
import { weLogin } from '@/api/http/user'
export default {
	props: {
	},
	data() {
		return {}
	},
	methods: {
		submitWeLogin() {
			// #ifdef APP-PLUS
			uni.getProvider({
				service: 'oauth',
				success: res => {
					if (~res.provider.indexOf('weixin')) {
						uni.login({
							provider: 'weixin',
							success: loginRes => {
								loginRes.code &&
									this.$store.dispatch('weChatLogin', {
										code: loginRes.code
									})
							}
						})
					}
				}
			})
			// #endif

			// #ifdef H5
			const appId = 'wxcec2f617e099800e'
			const redirectUri = `${window.location.host}/pages/user/login/index`
			window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=http://login.druglots.cn/&response_type=code&scope=snsapi_userinfo&state=${redirectUri}#wechat_redirect`
			// #endif
		}
	}
}
</script>

<style lang="scss" scoped>
.we_login_btn {
	background-color: #fff;
	width: 98rpx;
	height: 98rpx;
	margin: auto;
	margin-top: 35rpx;
	.we_icon {
		width: 100%;
		height: 100%;
	}
}
</style>
